<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        // 很多地方不适合用箭头函数

        // 1.箭头函数内部没有arguments对象

        function a() {
            console.log(arguments);
        }
        a(2, 44, 56, 3, 10);

        // let b = () => console.log(arguments);
        // b(6666); //arguments is not defined

        // 2.箭头函数不能当构造函数
        // let Person = () => {};
        // let dd = new Person(); // Person is not a constructor


        // 3.箭头函数内部，this指向外部作用域的this

        var name = 'zhangsan'; //这里用var 可以使用window来调用
        var obj = {
            name: 'lisi',
            fn1: function() {
                console.log(this.name); //lisi
            },
            fn2: () => console.log(this.name) //zhangsan
        }
        obj.fn1(); //this 指向obj
        obj.fn2(); //this 指向window
    </script>
</body>

</html>